$(document).ready(function(){
	$('#page-container').delegate('.slogan-item a.publish-it','click',function(){
		var $this=$(this);
		$.popover({
			url:$this.attr('href'),
			success:load_publish_cnt,
			offset_parent:$this.parents('.slogan-item')
		});
		return false;
	});
	$('#page-container').delegate('.slogan-item a.publisher','click',function(){
		var $this=$(this);
		$.popover({
			url:$this.attr('href'),
			offset_parent:$this.parents('.slogan-item')
		});
		return false;
	});
	$('#page-container').delegate('.slogan-item a.delete','click',function(){
		var $this=$(this);
		$.popover_confirm({
			message:"Do you really want to delete this slogan?",confirm:function(){
				$.ajax({
					url:$this.attr('href'),
					success:function(){
						$this.parents('.slogan-item').remove();
					}
				});
			},
			offset_parent:$this.parents('.slogan-item')
		});
		return false;
	});
	$('#page-container').delegate('.slogan-item .comment-input #CommentComment','focusin',function(){
		$form=$(this).parents('form');
		$('.btns',$form).css('opacity',0);
		$('.btns',$form).slideDown('fast',function(){
			$(this).animate({opacity:1.0},'fast');
		});
	});
	$('#page-container').delegate('.slogan-item .comment-input #CommentComment','focusout',function(){
		if($(this).val().length==0){
			$form=$(this).parents('form');
			$('.btns',$form).slideUp('fast');
		}
	});
	$('#page-container').delegate('.comment-open','click',function(){
		$this=$('.comment-input',$(this).parents('.cnt'));
		$this.css('opacity',0);
		$this.css('height',59);
		$('.btns',$this).show();
		$this.slideDown('fast',function(){
			$(this).animate({opacity:1.0},'fast');
			$('#CommentComment',$(this)).focus();
			$this.css('height','auto');
		});
		return false;
	});
	$('#page-container').delegate('.comment-page','click',function(){
		url=$(this).attr('href');
		if(!url)return false;
		$this=$(this).attr('href','');
		$.ajax({
			url:url,success:function(data){
				$('.page-cnt',$this.parents('.actions').siblings('.comment-cnt')).children().remove();
				$('.page-cnt',$this.parents('.actions').siblings('.comment-cnt')).append(data);
			}
		});
		return false;
	});
	$('#page-container').delegate('.comment-input .cancel','click',function(){
		$('#CommentComment',$(this).parents('form')).val("").focusout();
		return false;
	});
	$('#page-container').delegate('.comment-item a.remove','click',function(){
		var parent=$(this).parents('.comment-item');popover.get().load({
			url:$(this).attr('href'),callback:function(){
				$("a.confirm").click(function(e){
					parent.slideUp('fast');
				});
			},
			offsetParent:parent,horizon:'center',vertical:'middle'
		});
		return false;
	});
});